#!/usr/make
WORKSPACE=$(cd "$(dirname "$0")";pwd)
local_github_codesnippets_path="$WORKSPACE/CodeSnippets"

echo "是否导入/替换CodeSnippets(y/n):\c"
read -n1 res

small=$(echo $res | tr 'A-Z' 'a-z')

if [[ $small = "y" ]]; then
echo "\n"

    #Xcode中的CodeSnippets的路径
    xcode_codesnipets_path=~/Library/Developer/Xcode/UserData/CodeSnippets

    #删除旧模板
    rm -fr "$xcode_codesnipets_path"

    #复制文件
    cp -r "$local_github_codesnippets_path" "$xcode_codesnipets_path"
     
    #$? 上个命令的退出状态，或函数的返回值。
    if [ $? -eq 0 ]; then
        echo "😄 代码块已复制到~/Library/Developer/UserData/CodeSnippets\n"
    else
        echo "😔 ⚠️  😔 失败了\n"
    fi
    
else
    echo "请注意：您已取消！\n"
fi
